<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:composition template="/template.xhtml">
		<ui:define name="titulo">jPress - #{locale.cPanelTitle}</ui:define>
		<ui:define name="body">
			<div id="body-title">
				<h3>#{locale.cPanelOfTitle} #{sessionBean.logado.nome}</h3>
			</div>		
			<p:layout style="min-width:400px; min-height:800px;" id="layout">
				<div class="clear"></div>
			    <p:layoutUnit position="west" resizable="false" size="500" minSize="200" style="border: none">
					<p:panel header="#{locale.cPanelBlogsPanelTitle}" rendered="#{sessionBean.isAdmin}">
				    	<ui:repeat var="blog" value="#{sessionBean.meusBlogs}">
				    		<div class="ultimos">
				    			<span class="ultimos-titulo">#{blog.nome}</span><br />
				    			<span class="ultimos-descricao">#{blog.descricao}</span><br />
								<span class="ultimos-opcoes">
									<h:form>	
										<p:commandLink onclick="confirmation.show()" title="Excluir">
	                						<p:graphicImage value="${initParam.systemimages}crud_excluir.gif" display="inline-block" />
	                						Excluir
										</p:commandLink>
										<p:commandLink action="#{sessionBean.editarBlog}" title="Editar" ajax="false">
	                						<p:graphicImage value="${initParam.systemimages}crud_editar.gif" display="inline-block" />
	                						Editar
	                						<f:setPropertyActionListener target="#{sessionBean.selectBlog}" value="#{blog}" />
										</p:commandLink>
										<p:commandLink action="#{sessionBean.exibeBlog}" title="Acessar" ajax="false">
	                						<p:graphicImage value="${initParam.systemimages}crud_acessar.gif" display="inline-block" />
	                						Acessar
	                						<f:setPropertyActionListener target="#{sessionBean.selectBlog}" value="#{blog}" />
										</p:commandLink>
										<p:commandLink action="#{sessionBean.gerenciarBlog}" title="Gerenciar" ajax="false">
	                						<p:graphicImage value="${initParam.systemimages}crud_gerenciar.gif" display="inline-block" />
	                						Gerenciar
	                						<f:setPropertyActionListener target="#{sessionBean.selectBlog}" value="#{blog}" />
										</p:commandLink>																														
										<p:dialog header="Dialogo" widgetVar="confirmation" draggable="false" resizable="false" position="left">
    										<f:facet name="header">
    											Exclusão do blog
    										</f:facet>
											<center>  
	    										Tem certeza que quer excluir o blog <br /> <strong>#{blog.nome}</strong>?
	    										<br /><br />
	    										<p:commandButton value="Sim" update="growl, layout" oncomplete="confirmation.hide()" action="#{sessionBean.excluirBlog}" ajax="true">
	    											<f:setPropertyActionListener target="#{sessionBean.selectBlog}" value="#{blog}" />
	    										</p:commandButton>  
	        									<p:commandButton value="Não" onclick="confirmation.hide()" type="button" />
        									</center>  
										</p:dialog>
									</h:form>
								</span>				    			
				    		</div>
				    	</ui:repeat>
				    </p:panel>  
				    <p:panel header="#{locale.cPanelPostsPanelTitle}" rendered="#{sessionBean.isAdmin}" style="margin-top: 10px">  
				    	<ui:repeat var="post" value="#{sessionBean.meusPosts}">
				    		<div class="ultimos">
				    			<span class="ultimos-titulo">#{post.titulo}</span><br />
				    			<span class="ultimos-descricao">#{post.texto}</span><br />
								<span class="ultimos-opcoes">
									<h:form>	
										<p:commandLink onclick="confirmation2.show()" title="Excluir">
	                						<p:graphicImage value="${initParam.systemimages}crud_excluir.gif" display="inline-block" />
	                						Excluir
										</p:commandLink>
										<p:commandLink action="#{sessionBean.editarPost}" title="Editar" ajax="false">
	                						<p:graphicImage value="${initParam.systemimages}crud_editar.gif" display="inline-block" />
	                						Editar
	                						<f:setPropertyActionListener target="#{sessionBean.selectPost}" value="#{post}" />
										</p:commandLink>										
										<p:commandLink action="#{sessionBean.exibePost}" title="Acessar" ajax="false">
	                						<p:graphicImage value="${initParam.systemimages}crud_acessar.gif" display="inline-block" />
	                						Acessar
	                						<f:setPropertyActionListener target="#{sessionBean.selectPost}" value="#{post}" />
										</p:commandLink>																														
										<p:dialog header="Dialogo" widgetVar="confirmation2" draggable="false" resizable="false" position="left">
    										<f:facet name="header">
    											Exclusão do Post
    										</f:facet>
											<center>  
	    										Tem certeza que quer excluir o Post <br /> <strong>#{post.texto}</strong>?
	    										<br /><br />
	    										<p:commandButton value="Sim" update="growl, layout" oncomplete="confirmation2.hide()" action="#{sessionBean.excluirPost}" ajax="true">
	    											<f:setPropertyActionListener target="#{sessionBean.selectPost}" value="#{post}" />
	    										</p:commandButton>  
	        									<p:commandButton value="Não" onclick="confirmation2.hide()" type="button" />
        									</center>  
										</p:dialog>
									</h:form>
								</span>				    			
				    		</div>
				    	</ui:repeat>
				    </p:panel>  
			    </p:layoutUnit>
				<p:layoutUnit position="center" resizable="false" size="500" minSize="200" style="border: none">  
					<p:panel header="#{locale.cPanelMenuPanelTitle}" rendered="#{sessionBean.isAdmin}">
						<div id="menu-admin">
							<h:form>
								<p:commandLink action="#{sessionBean.criarBlog}" ajax="false">
									Criar Blog - internacionalizar
								</p:commandLink>
								<br />								
								<p:commandLink rendered="#{sessionBean.blogQtde != 0}" action="#{sessionBean.criarPost}" ajax="false">
									Novo post - internacionalizar
								</p:commandLink>
								<p:commandLink rendered="#{sessionBean.blogQtde != 0}" action="#{sessionBean.criarCustomPage}" ajax="false">
									<br/>Nova Custom Page - internacionalizar
								</p:commandLink>
							</h:form>
						</div>  
				    </p:panel>  
				    <p:panel header="#{locale.cPanelComentariosPanelTitle}" style="margin-top: 10px">  
				    	<ui:repeat var="comentario" value="#{sessionBean.meusComentarios}">
				    		<div class="ultimocomentario">
				    			<span class="ultimocomentario-texto">
				    				Comentario: #{comentario.texto}
				    			</span><br />
				    		</div>
				    	</ui:repeat>
				    </p:panel>
			    </p:layoutUnit> 
			</p:layout>
			<div class="clear"></div>
		</ui:define>
	</ui:composition>
</html>